Filter MCPServer capabilities by registered primitives#2477
Filter MCPServer capabilities by registered primitives#2477MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
|
Advertising capabilities that have no registered handlers is a sneaky source of compatibility issues — clients that enumerate capabilities and then try to call an unregistered primitive get confusing 'method not found' errors instead of a clean capability negotiation failure. Filtering at the capability advertisement level is the right place to fix this. Does the change affect the |
|
@rendina-io Good question — short answer: The filter I added (
The actual Happy to add a test that nails that invariant down (e.g. assert that with zero registered tools, |
Summary
MCPServerfrom advertising prompt, resource, and tool capabilities when nothing has been registered for that primitiveServerbehavior unchanged by making the filtering opt-inTesting
python3 -m py_compile src/mcp/server/lowlevel/server.py src/mcp/server/mcpserver/server.py tests/server/mcpserver/test_server.pypytest tests/server/mcpserver/test_server.py -k capability(not run locally:pytestis not installed in this environment)